﻿using System.Windows.Forms;

namespace Microsoft.WowAddonStudio.FrameXml.Components.Events.Editors
{
    /// <summary>
    /// 
    /// </summary>
    public partial class EventEditorForm : Form
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="EventEditorForm"/> class.
        /// </summary>
        public EventEditorForm()
        {
            InitializeComponent();

            Icon = Resources.WowAddonStudio;
        }

        /// <summary>
        /// Gets or sets the script.
        /// </summary>
        /// <value>The script.</value>
        public string Script
        {
            get { return textBoxScript.Text; }
            set { textBoxScript.Text = value; }
        }

        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.KeyDown"/> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.KeyEventArgs"/> that contains the event data.</param>
        /// <remarks>Handles Ctrl+Enter (accept window)</remarks>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return && e.Control)
            {
                e.Handled = true;
                DialogResult = DialogResult.OK;
                Close();
            }
            base.OnKeyDown(e);
        }
    }
}